package avicit.bdp.dcs.stream.dto;

import avicit.bdp.dcs.tools.enums.MeasureParaTypeEnum;
import io.swagger.annotations.ApiModelProperty;

import java.util.Objects;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2020-10-16
 * @类说明：MeasureParaDto
 * @修改记录：
 * @注意事项：
 * @说明：消息模板中测量参数Entity
 */
public class MeasureParaDto {

    @ApiModelProperty(value = "消息模板主键ID")
    private String id;

    @ApiModelProperty(value = "设备ID")
    private String deviceId;

    // 当前只有json序列化方式需要此参数
    @ApiModelProperty(value = "参数前缀")
    private String prefix;

    @ApiModelProperty(value = "参数名称")
    private String name;

    @ApiModelProperty(value = "参数数据类型")
    private MeasureParaTypeEnum type;

    @ApiModelProperty(value = "参数说明")
    private String remark;

    public String getId() {
        return id;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public String getPrefix() {
        return prefix;
    }

    public String getName() {
        return name;
    }

    public MeasureParaTypeEnum getType() {
        return type;
    }

    public String getRemark() {
        return remark;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setType(MeasureParaTypeEnum type) {
        this.type = type;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * 覆写equals，保证HashSet中值不重复
     * @param obj
     * @return
     */
    @Override
    public boolean equals(Object obj) {
        if(!(obj instanceof MeasureParaDto)) {
            return false;
        }

        MeasureParaDto measureDefinition = (MeasureParaDto) obj;
        if (this == measureDefinition) {
            return true;
        }

        // 如果prefix、name相等，则二者一致
        if (measureDefinition.name.equals(this.name)) {
            return true;
        }

        return false;
    }

    /**
     * 覆写hashCode
     * @return
     */
    @Override
    public int hashCode() {
        return Objects.hash(this.name);
    }

    /**
     * 覆写clone
     * @return
     * @throws CloneNotSupportedException
     */
    @Override
    public Object clone() throws CloneNotSupportedException {
        Object obj=super.clone();

        return obj;
    }

}
